<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { TestPatientResult } from '@/types/healthTest'
import { getPatientResult } from '@/services/healthTest.ts'
import { useMemberStore } from '@/stores'

const memberStore = useMemberStore()
const profile = memberStore.profile
const messagelist = ref<TestPatientResult[]>([])

const openTest = async () => {
  if (profile.patientId) {
    const res = await getPatientResult(profile.patientId)
    messagelist.value = res.data
  } else {
    console.error('Patient ID is not available in the profile.')
  }
}

onMounted(openTest)
</script>

<template>
  <view class="card" v-for="index in messagelist" @tap="openTest(index)">
    <view class="ask">{{ index.htResTitle }}</view>
    <view class="mes">{{ index.htResContent }}</view>
  </view>
</template>

<style lang="scss" scoped>
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin: 10px;
  padding: 15px;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.ask {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.mes {
  font-size: 16px;
  color: #666;
  line-height: 1.5;
}
</style>
